package wms

import (
	"context"
	"ez/apps/wms/auto/mc"
	"fmt"
	"gitee.com/dreamwood/ez-go/db/mgo"
	"gitee.com/dreamwood/ez-go/ez"
	"gitee.com/dreamwood/ez-go/ss"
	"go.mongodb.org/mongo-driver/mongo"
)

func (this *AttributeKey) MakeChoice() *ss.M {
	return &ss.M{
		"value": this.Id,
		"label": this.Name,
	}
}

type AttributeKeyCrud struct {
	Factory *mgo.Factory
}

func NewAttributeKeyCrud(args ...interface{}) *AttributeKeyCrud {
	factory := mgo.NewFactory(args...)
	factory.SetDoc(&AttributeKey{})
	factory.SetArgus(mc.GetAttributeKeyConfig())
	crud := &AttributeKeyCrud{
		Factory: factory,
	}
	return crud
}
func (this *AttributeKeyCrud) GetCollection() *mongo.Collection {
	return this.Factory.GetCollection()
}
func (this *AttributeKeyCrud) FindId(id int64) (*AttributeKey, error) {
	md := new(AttributeKey)
	e := this.Factory.FindId(md, id)
	return md, e
}
func (this *AttributeKeyCrud) FindBy(where ss.M, order []string, page int, limit int) ([]*AttributeKey, error) {
	list := make([]*AttributeKey, 0)
	qb := &ez.HttpQuery{
		Conditions: where,
		Order:      order,
		Page:       page,
		Limit:      limit,
	}
	e := this.Factory.FindBy(&list, qb)
	return list, e
}
func (this *AttributeKeyCrud) FindOneBy(where ss.M, order []string) (*AttributeKey, error) {
	md := new(AttributeKey)
	qb := &ez.HttpQuery{
		Conditions: where,
		Order:      order,
	}
	e := this.Factory.FindOneBy(md, qb)
	return md, e
}
func neverUsed_AttributeKey_func() {
	//导入ss包
	a := ss.M{}
	fmt.Printf("%v", a)
	fmt.Printf("%v", context.TODO())
}
